$(function() {	
	//启用拖拽
	Common.DragStart($(".org_header")[0]);

	$(".close").bind("click", function() {
		winClose();
	});
	var org = null;
	ShowLoading();
	App.getOrg(function(data) {				
		//初始化数据		
		UserList.InitData(data);
		//设置已选择人员	
		UserList.SetSelUsers(window.returnValue);	
		//页面渲染
		UserList.InitPage();	
		HideLoading();		
	}, function(err) {
		Common.ShowTips(err);
	});
	//确定，返回选择人员
	$("#btn_confirm").bind("click", function() {
		winConfirm();
	});
	//取消，关闭当前窗口，显示父级窗口
	$("#btn_cancel").bind("click", function() {
		winClose();
	});
});
function ShowLoading() {
	$(".org_loading").show();
}

function HideLoading() {
	$(".org_loading").hide();
}

function winConfirm() {
	window.nativeWindow.close();
	var loginWindow = air.NativeApplication.nativeApplication.openedWindows;
	//window.nativeWindow.close();
	for(var i = 0; i < loginWindow.length; i++) {
		if(loginWindow[i].title === "回复寻呼") {
			App.setTempData(UserList.GetSelUsers(2));
			loginWindow[i].activate();
			break;
		}
	}
}

function winClose() {
	window.nativeWindow.close();
	var loginWindow = air.NativeApplication.nativeApplication.openedWindows;
	//window.nativeWindow.close();
	for(var i = 0; i < loginWindow.length; i++) {
		if(loginWindow[i].title === "回复寻呼") {
			App.setTempData("|");
			loginWindow[i].activate();
			break;
		}
	}
}